'use strict';
// Copyright 2014 Blueant Inc. All Rights Reserved.

/**
 * @fileoverview 任务
 * @author sundbcn@gmail.com (sun debing)
 */

var modelUtil = require('../util/modelUtil');
var mongoConnector = require('../libs/mongodb/mongoConnector');
/* jshint unused:false */
var taskSchema = require('../schemas/taskSchema');
var Task = mongoConnector().model('Task');

/**
 * 根据role_id获取用户
 * @return {[type]} [description]
 */
module.exports.getByRoleId = function (role_id, cb) {
    modelUtil.getByRoleId(Task, role_id, function (err, task_model) {
        if (!!err) {
            console.error(err);
            return cb(err);
        }

        _initTask(task_model);
        cb(null, task_model);
    });
};

/**
 * 初始化任务
 * @param  {[type]}   task_model [description]
 * @param  {Function} cb         [description]
 * @return {[type]}              [description]
 */
var _initTask = function (task_model) {
    task_model.refreshFollowTask();
};
